/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.azon.ip.utils;

/**
 *
 * @author Ahmad Fauzan
 */
public class Matrix3x3 {
    
    float[] number;
    
    public Matrix3x3() {
        number = new float[9];
    }
    
    public Matrix3x3(float[] matix) {
        number = new float[9];
        for(int i=0; i < matix.length; i++) {
            number[i] = matix[i];
        }
    }
    
    public float dot(Matrix3x3 mat) {
        float res = 0;
        for(int i=0; i < 9; i++) {
            res = number[i] * mat.number[i];
        }
        return res;
    }
    
    public void rotate45() {
        float temp = number[0];
        number[0] = number[3];
        number[3] = number[6];
        number[6] = number[7];
        number[7] = number[8];
        number[8] = number[5];
        number[5] = number[2];
        number[2] = number[1];
        number[1] = temp;
    }
    
    public void rotate90() {
        rotate45();
        rotate45();
    } 
    
    public float[] getMatrixArray() {
        return number;
    }

    @Override
    public String toString() {
        String res = "";
        for(int i=0 ; i < 9; i+=3) {
            res += number[i] + ","+ number[i+1] + "," + number[i+2] + "\n"; 
        }
        return res;
    }
    
    
}
